<?php


function crowFather( $query , $returnType){

	#Easy SQL queries. Gimme a query , I'll execute it for you. The second var is the return type
	#
	#1=fetchAll
	#2=rowCount
	#3=No data returned - returns 0 on completion
	#4=fetchAll
	#5=rowCount for all drivers. Must be a count.
	#6=returns good SQL string
	#
	#With this we will know all
	#
	$PDO_hostname = 'localhost';
	$PDO_username = 'chatboss';
	$PDO_password = 'chatboss';
	$PDO_database = 'chatboss';
	global $PDO_db;
	
	if(isset($query) && isset($returnType))
	{
		try
		{
			$PDO_db = new PDO('mysql:host='.$PDO_hostname.';dbname='.$PDO_database.';charset=utf8',$PDO_username,$PDO_password);
			if($returnType != 6 )
			{
				$queryMechanism = $PDO_db->prepare($query);
				$queryMechanism->execute();
			}
			
			switch ($returnType){
			
				case 1:
					return $queryMechanism->fetchAll();
					break;
				case 2:
					return $queryMechanism->rowCount();
					break;
				case 3:
					#return 0;
					break;
				case 4:
					return $queryMechanism->fetchAll(PDO::FETCH_NUM);
					break;
				case 5:
					return $queryMechanism->fetchColumn();
					break;
				case 6:
					return $PDO_db->quote($query);
					break;
				default:
					return "#Error: returnType incorrect";
					break;
			}
			
			$queryMechanism->closeCursor();
		}
		catch (PDOException $exception)
		{
			return $exception;
		}
	}
	else
	{
		return "Incorrect values were specified";
	}

}
?>
